package Day009_Map_斗地主_冒泡排序.ZuoYe;

import java.util.Arrays;

public class Test3 {
    public static void main(String[] args) {
        int[] arr = {1,2,432,32,54,32,3,7,657,563,25,43,6,463,52};
        System.out.println(Arrays.toString(arr));
        //冒泡排序
        //升序
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0;j < arr.length-1-i;j++){
                if (arr[j] > arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));

        //降序
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0;j < arr.length-1-i;j++){
                if (arr[j] < arr[j+1]){
                    int temp = arr[j+1];
                    arr[j+1] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
